package util;


import static content.common.ResultMessage.USER_UNLOGIN;

public class ThreadLocalUtil<T> {
    private ThreadLocal<T> threadLocal = new ThreadLocal<>();

    public void set(T token) {
        threadLocal.set(token);
    }

    public T get() {
        T token = threadLocal.get();
        if (token == null) {
            throw new UnloginException(USER_UNLOGIN);
        }
        return token;
    }

    public void remove() {
        threadLocal.remove();
    }

}
